package com.boot.demo.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.boot.demo.dao.DemoDao;
import com.boot.demo.service.DemoService;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;

import javax.annotation.Resource;

@Service
public class DemoServiceImpl implements DemoService{
	
	@Autowired
	private DemoDao demoDao;

	@Resource
	private JedisPool jedisPool;

	@Override
	public String queryDataStr(String str) {
		try {
			
			String idno = demoDao.getString(str);
			
			return idno;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return "";
		
	}

	@Override
	public String queryCache() {
		Jedis jedis = jedisPool.getResource();
		jedis.setex("test",60,"testValue");
		String cacheS = jedis.get("test");
		return cacheS;
	}
}
